package crud

import (
	"fmt"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"goods/internal/svc"
)

var Client sqlx.SqlConn

func InitMysql(svcCtx *svc.ServiceContext) {
	mysqlConf := svcCtx.Config.Mysql
	datasource := fmt.Sprintf(
		"%v:%v@tcp(%v:%v)/%v",
		mysqlConf.User,
		mysqlConf.Password,
		mysqlConf.Host,
		mysqlConf.Port,
		mysqlConf.DBName,
	)
	Client = sqlx.NewMysql(datasource)
}
